# -*- coding: utf-8 -*-
# @Time    : 2021/1/4 上午11:20
# @Author  : tgy
# https://leetcode-cn.com/problems/ba-shu-zi-fan-yi-cheng-zi-fu-chuan-lcof/

class Solution:
    def translateNum(self, num: int) -> int:
        ...
        chars = tuple(str(num))
        self.num = 0
        self.translate(chars, 0)
        return self.num

    def translate(self, chars,index):

        chars_len = len(chars)
        if chars_len == index:
            self.num += 1
            return
        # 取一位，
        self.translate(chars, index+1)
        # 取两位
        if index + 1 < chars_len and \
            (chars[index] == '1' or (chars[index] == '2' and chars[index + 1] < '6')):
            self.translate(chars, index + 2)


if __name__ == '__main__':
    ...
    solution = Solution()
    num = solution.translateNum(12258)
    print(num)
